Strict

Import agfx

Global myTmpScreen:TTmpScreen

Class TAgfx_test_app Extends TFramework

	Method OnCreate:Int()
		
		Super.OnCreate()
				
		myTmpScreen = New TTmpScreen		
		myTmpScreen.Prepare()
		
		Return 0
	End
	

End


Class TTmpScreen Extends TScreen
	
	Field v_point:TVerletPoint
	Field velocity:TVector2 
	Field gravity:TVector2 
	Field speed:Float = 1.0
	Field range:TBBox
	
	' START when app is created
	Method Start:Void()
		Self.v_point = New TVerletPoint(320,60,20,True)		
		Self.v_point.SetGravity(New TVector2(0,0))
				
		Self.velocity = New TVector2()
		
		Self.range = New TBBox()
		Self.range.Set(New TVector2(DISPLAY.VSCREEN_HALF_WIDTH,DISPLAY.VSCREEN_HALF_HEIGHT),New TVector2(DISPLAY.VSCREEN_WIDTH,DISPLAY.VSCREEN_HEIGHT),DISPLAY.VSCREEN_HALF_WIDTH)
	End
	
	' main app logic loop update
	Method Update:Void()
	
		If KeyDown(KEY_UP) Then Self.velocity.y=-Self.speed
		If KeyDown(KEY_DOWN) Then Self.velocity.y=Self.speed
		If KeyDown(KEY_LEFT) Then Self.velocity.x=-Self.speed
		If KeyDown(KEY_RIGHT) Then Self.velocity.x=Self.speed
		
		
		Self.v_point.SetForce(Self.velocity)		
		Self.v_point.Update()
		Self.v_point.IterateRangeCollision(Self.range)
	End
	
	' main app render loop
	Method Render:Void()
		Cls
		Self.v_point.Render()
	End
End
